package com.financing.wap.util;

import java.util.Date;

import com.financing.wap.common.Session;
import com.financing.wap.common.SessionUtil;
import com.financing.wap.dto.BaseDTO;
import com.financing.wap.dto.BaseToDTO;
import com.financing.wap.dto.DstUserInfoDTO;

public class DTOdateSetUtil {
	public static final String  user = "USER";
	/**
	 * 
	* @Title: setUpdateOrCreateInfo 
	* @Description: 设置记录创建人信息
	* @param @param baseDTO
	* @param @return    
	* @return BaseDTO   
	* @throws
	 */
	public static final BaseDTO setCreateInfo(BaseDTO baseDTO){
		String  createBy = Constants.PLATFORM_ADMIN_NAME;
		Session session = SessionUtil.getSession();
		
		if(session != null && session.getUser() != null){
			DstUserInfoDTO loginUser = session.getUser();
			createBy = loginUser.getId().toString();
		}
		if(null != baseDTO){
			baseDTO.setCreateDate(new Date(System.currentTimeMillis()));
			baseDTO.setCreateBy(createBy);
			baseDTO.setDeleteTag("1");
		}
		return baseDTO;
	}
	/**
	 * 
	* @Title: setUpdateOrCreateInfo 
	* @Description: 设置记录创建人信息
	* @param @param baseDTO
	* @param @return    
	* @return BaseDTO   
	* @throws
	 */
	public static final BaseToDTO setCreateInfo(BaseToDTO baseDTO){
		String  createBy = Constants.PLATFORM_ADMIN_NAME;
		Session session = SessionUtil.getSession();
		
		if(session != null && session.getUser() != null){
			DstUserInfoDTO loginUser = session.getUser();
			createBy = loginUser.getId().toString();
		}
		if(null != baseDTO){
			baseDTO.setCreateDate(new Date(System.currentTimeMillis()));
			baseDTO.setCreateBy(createBy);
			baseDTO.setDeleteTag("1");
		}
		return baseDTO;
	}
	
	/**
	 * 
	* @Title: setUpdateOrCreateInfo 
	* @Description: 设置记录修改人信息
	* @param @param baseDTO
	* @param @return    
	* @return BaseDTO   
	* @throws
	 */
	public static final BaseDTO setUpdateInfo(BaseDTO baseDTO){
		String updateBy = Constants.PLATFORM_ADMIN_NAME;
		
		Session session = SessionUtil.getSession();
		if(session != null && session.getUser() != null){
			DstUserInfoDTO loginUser = session.getUser();
			updateBy = loginUser.getId().toString();
		}
		
		if(null != baseDTO){
			baseDTO.setUpdateDate(new Date(System.currentTimeMillis()));
			
			baseDTO.setUpdateBy(updateBy);
		}
		return baseDTO;
	}
	/**
	 * 
	* @Title: setUpdateOrCreateInfo 
	* @Description: 设置记录修改人信息
	* @param @param baseDTO
	* @param @return    
	* @return BaseDTO   
	* @throws
	 */
	public static final BaseToDTO setUpdateInfo(BaseToDTO baseDTO){
		String updateBy = Constants.PLATFORM_ADMIN_NAME;
		
		Session session = SessionUtil.getSession();
		if(session != null && session.getUser() != null){
			DstUserInfoDTO loginUser = session.getUser();
			updateBy = loginUser.getId().toString();
		}
		
		if(null != baseDTO){
			baseDTO.setUpdateDate(new Date(System.currentTimeMillis()));
			
			baseDTO.setUpdateBy(updateBy);
		}
		return baseDTO;
	}
}
